<div class="row clearfix">
    <form action="/?fn=package" method="get" name="form1" id="form1">
        <table class="table table-hover table-condensed table-bordered">
            <tr>
                <th>类型</th>
                <th>
                    <input type="radio" value="game" id="game" name="version" checked="checked"/>游戏
                    <input type="radio" value="iiapple" id="iiapple" name="version"/>I苹果
                </th>
            </tr>
            <tr>
                <th>原包</th>
                <th>
                    <select id="packName">
                        <option value=0>选择原包</option>
                        <?php foreach($packName as $key=> $val) {
                            echo "<option value='". $val ."'>". $val ."</option>";
                        } ?>
                    </select>
                </th>
            </tr>
            <tr>
                <th>授权文件</th>
                <th>
                    <select id="confName">
                        <option value=0>选择授权文件</option>
                        <?php foreach($confName as $key=> $val) {
                            echo "<option value='". $val ."'>". $val ."</option>";
                        } ?>
                    </select>
                </th>
            </tr>
            <tr>
                <th>游戏</th>
                <th>
                    <select id="selectGame">
                        <option value=0>选择游戏</option>
                        <?php foreach($allGame as $val) {
                            echo "<option value='". $val->soft_id ."'>". $val->soft_name ."</option>";
                        } ?>
                    </select>
                </th>
            </tr>
            <tr>
                <th>渠道</th>
                <th>
                    <select id='channel'>
                        <option value=0>选择渠道</option>
                        <?php foreach($channel as $key=> $val) {
                            echo "<option value='". $key ."'>". $val ."</option>";
                        } ?>
                    </select>
                </th>
            </tr>
            <tr>
                <th>打包</th>
                <th>
                    <input type="button" value="开始重签" id="button" name="button"/>
                    <img src="img/loading.gif" id="imgloading" style="display: none">
                    <a href="<?php echo $url; ?> " style="display: none" id="downpack"> 下载包 </a>
                </th>
            </tr>
        </table>
    </form>
</div>
</div>

<script>
    $(document).ready(function(){
        $('#button').bind('click', function(){
            var type = $('#form1').find("input:radio").val();
            //var cerkey = $('#cerkey').val();
            var packName = $('#packName').val();
            var confName = $('#confName').val();
            var channel  = $('#channel').val();
            var softId   = $('#selectGame').val();
            if(packName ==0 || confName == 0) {
                alert('包和授权证书必须选择');
                return false;
            }

            if(channel ==0) {
                alert('渠道必选');
                return false;
            }

            if(type == 'game') {
                if(softId ==0) {
                    alert('游戏必选');
                    return false;
                }
            }
            //$("#button").attr({ "class": "banner", "alt": "头像", "src": "img/loading.gif" });
            $('#imgloading').css('display' ,'block');
            $.get('/?fn=signature&type='+type+'&packName='+packName+'&confName='+confName+'&channel='+channel+'&softId='+softId, function(res){
                $('#imgloading').css('display' ,'none');
                $('#downpack').css('display' ,'block');

                $.get("<?php echo $downIp;?>:55757/?fn=files",function(data){
                    $("a").attr("href","<?php echo $downUrl;?>/package/"+data);
                 });
            });
           // $('#form1').submit();
        });
    });
</script>